﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 数组的使用
{
    class Program
    {
        static void Main(string[] args)
        {
            //int[] array = new int[3] { 0, 1, 2 };
            //Console.WriteLine(array[2]);

            //int[] array2 = { 1, 2, 3 };
            //Console.WriteLine(array2[2]);

            //int[] array3 = new int[5]{ 1, 2, 3 }; // 错误的，个数和申明数必须一致，否则出错，这点与C语言不同，C中默认后面的为0
            //Console.WriteLine(array3[2]);

            //Array.Resize(ref array, 5);  //调整array数组的长度为5，必须有关键词 ref
            //array[4] = 1;
            //Console.WriteLine(array[4]);

            //string[] strings = new string[4] { "haha", "hehe", "xixi", "heihei" };
            //for (int i = 0; i < strings.Length / 2; i++)
            //{
            //    string temp = strings[i];
            //    strings[i] = strings[strings.Length - i - 1];
            //    strings[strings.Length - i - 1] = temp;
            //}

            //for (int i = 0; i < strings.Length; i++)
            //{
            //    Console.WriteLine(strings[i]);
            //}

            //int[] array1 = { 0, 1, 2 };
            //int[] array2 = { 3, 4, 5 };
            //int[] array = new int[array1.Length + array2.Length];
            //for (int i = 0; i < array1.Length; i++)
            //{
            //    array[i] = array1[i];
            //}

            //for (int i = 0; i < array2.Length; i++)
            //{
            //    array[array1.Length + i] = array2[i];
            //}
            //for (int i = 0; i < array.Length; i++)
            //{
            //    Console.WriteLine(array[i]);
            //}
                Console.ReadKey();
        }
    }
}
